package com.chenwb.concurrency.thread;

public class ThreadPriority {

	private static class OutTask implements Runnable {

		@Override
		public void run() {
			System.out.println(Thread.currentThread().getName()+"线程：优先级为"+Thread.currentThread().getPriority());
			Thread innerTask = new Thread(new InnerTask(),"InnerTask");
			innerTask.start();
			try {
				innerTask.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	private static class InnerTask implements Runnable {

		@Override
		public void run() {
			System.out.println(Thread.currentThread().getName()+"线程：优先级为"+Thread.currentThread().getPriority());
		}
	}

	/**
	 * 默认priority=5
	 * @param args
	 */
	public static void main(String[] args) throws InterruptedException {
		Thread outTask = new Thread(new OutTask(),"OutTask");
		outTask.setDaemon(true);
		outTask.start();
		outTask.join();
	}

}
